<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 站点图标 -->
    <link rel="icon" type="image/png" sizes="32x32" href="{{ url_for('static', filename='images/favction.png') }}">
    <link rel="icon" type="image/png" sizes="16x16" href="{{ url_for('static', filename='images/favction.png') }}">
    <title>修改密码 - SkitPanel 短剧管理面板</title>
    <!-- Tailwind CSS -->
    <script src="https://cdn.tailwindcss.com"></script>
    <!-- Font Awesome -->
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <!-- Change Password CSS -->
    <link rel="stylesheet" href="{{ url_for('static', filename='css/change_password.css') }}">
    
    <!-- 自定义Tailwind配置 -->
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#3b82f6',
                        secondary: '#10b981',
                        dark: '#1e293b',
                        light: '#f8fafc',
                    },
                    fontFamily: {
                        sans: ['Inter', 'system-ui', 'sans-serif'],
                    },
                }
            }
        }
    </script>
    
    <!-- 自定义工具类 -->
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .form-shadow {
                box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
            }
            .input-focus {
                @apply focus:ring-2 focus:ring-primary/50 focus:border-primary transition-all duration-200;
            }
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen flex flex-col">
    <!-- 头部导航 -->
    <header class="bg-white shadow-lg z-10 border-b-2 border-primary/20">
        <div class="container mx-auto px-4 py-4 flex justify-between items-center">
            <!-- 移动端菜单按钮 -->
            <button id="menu-button" class="md:hidden text-gray-600 hover:text-primary p-2 rounded-full hover:bg-gray-100 transition-colors duration-200 mr-2">
                <i class="fa fa-bars text-xl"></i>
            </button>
            
            <div class="flex items-center space-x-2">
                <i class="fa fa-film text-primary text-2xl"></i>
                <h1 class="text-xl font-bold text-dark">Skit-Panel 短剧管理面板</h1>
            </div>
        </div>
    </header>

    <!-- 主内容区 -->
    <div class="flex-1 overflow-hidden">
        <!-- 主内容 -->
        <main class="flex-1 overflow-auto p-4">
            <div class="max-w-md mx-auto bg-white rounded-xl form-shadow p-6">
                <h2 class="text-xl font-bold text-gray-800 mb-6 flex items-center">
                    <i class="fa fa-key text-primary mr-2"></i>
                    修改密码
                </h2>
                
                {% if session.get('password_reset_required') %}
                <div class="mb-6 p-4 bg-yellow-50 border-l-4 border-yellow-400 text-yellow-700 rounded-lg">
                    <div class="flex">
                        <div class="flex-shrink-0">
                            <i class="fa fa-exclamation-triangle text-xl text-yellow-500"></i>
                        </div>
                        <div class="ml-3">
                            <p class="font-medium">请设置新密码</p>
                            <p class="mt-1 text-sm">您是首次登录或使用了系统生成的初始密码，请设置一个安全的新密码。</p>
                        </div>
                    </div>
                </div>
                {% endif %}
                
                {% with messages = get_flashed_messages(with_categories=true) %}
                    {% if messages %}
                        {% for category, message in messages %}
                            <div class="mb-4 p-3 rounded-lg {% if category == 'error' %}bg-red-50 text-red-700 border border-red-200{% else %}bg-green-50 text-green-700 border border-green-200{% endif %}">
                                {{ message }}
                            </div>
                        {% endfor %}
                    {% endif %}
                {% endwith %}
                
                <form method="POST" action="{{ url_for('change_password') }}">
                    <div class="mb-4">
                        <label for="old_password" class="block text-sm font-medium text-gray-700 mb-1">当前密码</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa fa-lock text-gray-400"></i>
                            </div>
                            <input type="password" id="old_password" name="old_password" required
                                   class="w-full pl-10 pr-10 py-2 border border-gray-300 rounded-lg shadow-sm input-focus"
                                   placeholder="请输入当前密码">
                            <button type="button" id="toggle-old-password" class="absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600 transition-colors duration-200">
                                <i class="fa fa-eye-slash" aria-hidden="true"></i>
                            </button>
                        </div>
                    </div>
                    
                    <div class="mb-4">
                        <label for="new_password" class="block text-sm font-medium text-gray-700 mb-1">新密码</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa fa-key text-gray-400"></i>
                            </div>
                            <input type="password" id="new_password" name="new_password" required
                                   class="w-full pl-10 pr-10 py-2 border border-gray-300 rounded-lg shadow-sm input-focus"
                                   placeholder="请输入新密码">
                            <button type="button" id="toggle-new-password" class="absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600 transition-colors duration-200">
                                <i class="fa fa-eye-slash" aria-hidden="true"></i>
                            </button>
                        </div>
                        <p class="mt-1 text-xs text-gray-500">密码至少包含8个字符，包括大小写字母、数字和特殊字符</p>
                    </div>
                    
                    <div class="mb-6">
                        <label for="confirm_password" class="block text-sm font-medium text-gray-700 mb-1">确认新密码</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa fa-key text-gray-400"></i>
                            </div>
                            <input type="password" id="confirm_password" name="confirm_password" required
                                   class="w-full pl-10 pr-10 py-2 border border-gray-300 rounded-lg shadow-sm input-focus"
                                   placeholder="请再次输入新密码">
                            <button type="button" id="toggle-confirm-password" class="absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600 transition-colors duration-200">
                                <i class="fa fa-eye-slash" aria-hidden="true"></i>
                            </button>
                        </div>
                    </div>
                    
                    {% if session.get('password_reset_required') %}
                    <!-- 强制重置密码时，只显示确认按钮 -->
                    <div class="flex">
                        <button type="submit" class="w-full bg-primary hover:bg-primary/90 text-white font-medium py-2 px-4 rounded-lg transition-colors duration-200">
                            <i class="fa fa-check mr-1"></i> 确认修改
                        </button>
                    </div>
                    {% else %}
                    <!-- 普通修改密码时，显示确认和取消按钮 -->
                    <div class="flex space-x-3">
                        <button type="submit" class="flex-1 bg-primary hover:bg-primary/90 text-white font-medium py-2 px-4 rounded-lg transition-colors duration-200">
                            <i class="fa fa-check mr-1"></i> 确认修改
                        </button>
                        <a href="{{ url_for('user_center') }}" class="flex-1 bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium py-2 px-4 rounded-lg transition-colors duration-200 text-center">
                            <i class="fa fa-times mr-1"></i> 取消
                        </a>
                    </div>
                    {% endif %}
                </form>
            </div>
        </main>
    </div>

    <!-- 页脚 -->
    <footer class="bg-white py-6 border-t-2 border-gray-100 shadow-inner">
        <div class="container mx-auto px-4 text-center text-gray-500 text-sm">
            <p>© 2025 Skit-Panel 短剧管理面板 - 作者：DoubleStackWorkShop</p>
        </div>
    </footer>

    <!-- Base JavaScript -->
    <script src="{{ url_for('static', filename='js/base.js') }}"></script>
    
    <!-- Change Password JavaScript -->
    <script src="{{ url_for('static', filename='js/change_password.js') }}"></script>
</body>
</html>